/*
 * @Author: 蔡霸霸
 * @Date: 2020-05-09 16:34:30
 * @LastEditors: 蔡霸霸
 * @LastEditTime: 2020-06-17 10:32:07
 * @FilePath: \Nuxt_music\middleware\route.js
 */

// 中间件 middle/ route.js
export default function({ isHMR, app, store, route, params, error, redirect }) {
  if (isHMR) return
  // 重定向
  if (route.fullPath === '/') {
    return redirect('/home')
  }

  // 如果是url中包含home页面及其子页面那么就更改vuex的state改变红条状态栏的显示状态
  if (route.path.includes('home')) {
    return store.commit('set_showNav', true)
  } else {
    return store.commit('set_showNav', false)
  }
}
